package com.hongfeng.support.service.common;

import java.io.Serializable;
import java.util.List;

import com.hongfeng.support.common.Page;
import com.hongfeng.support.item.OrderItem;
import com.hongfeng.support.item.ParmItem;

public interface GenericService<T, PK extends Serializable> {

	/** Persist the new entity object into database */
	public void create(T entity);

	/**
	 * Retrieve an object that was previously persisted to the database using
	 * the indicated id as primary key
	 */
	public T read(PK id);

	/**
	 * Copy the state of the given object onto the persistent object with the
	 * same identifier.
	 */
	public void update(T entity);

	/** Remove an object from persistent storage in the database */
	public void delete(PK id);

	public List<T> findAll();

	public List<T> findAllByQuery(Class<T> clazz, ParmItem parm);

	public List<T> findAllByQuery(Class<T> clazz, List<ParmItem> parms);

	public List<T> findAllByQuery(Class<T> clazz, ParmItem parm, OrderItem order);

	public List<T> findAllByQuery(Class<T> clazz, List<ParmItem> parms,
			List<OrderItem> orders);

	public Page<T> findPage(Page<T> page);

	public Page<T> findPageByQuery(Page<T> page, Class<T> clazz, ParmItem parm);

	public Page<T> findPageByQuery(Page<T> page, Class<T> clazz,
			List<ParmItem> parms);

	public Page<T> findPageByQuery(Page<T> page, Class<T> clazz, ParmItem parm,
			OrderItem order);

	public Page<T> findPageByQuery(Page<T> page, Class<T> clazz,
			List<ParmItem> parms, List<OrderItem> orders);

}
